package com.literature.search.core.utils;


import org.springframework.util.StringUtils;

import java.lang.reflect.Field;
import java.util.List;
/**
 * @ClassName ObjectUtil
 * @Description TODO
 * @Author abin
 * @Date 2023/3/2 22:04
 * @Version 1.0
 */
public class ObjectUtil {
    /**
     * 判断对象中部分属性值是否不为空
     *
     * @param object       对象
     * @param excludeFieldNames 选择忽略校验的属性名称List集合
     * @return
     */
    public static boolean checkObjFieldsIsNotNull(Object object, List<String> excludeFieldNames) {
        if (null == object) {
            return false;
        }

        try {
            for (Field f : object.getClass().getDeclaredFields()) {
                f.setAccessible(true);
                if (!excludeFieldNames.contains(f.getName()) && f.get(object) == null) {
                    return false;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return true;
    }
}
